package com.itcoon.cloud.framework.mybatis.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.itcoon.cloud.framework.mybatis.core.IdDO;
import com.itcoon.cloud.framework.mybatis.core.Page;
import com.itcoon.cloud.framework.mybatis.mapper.XBaseMapper;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

public interface XService<M extends XBaseMapper<T>, T extends IdDO> extends IService<M, T>{

    @Override
    M getBaseMapper();

    boolean removeRealById(Serializable id);

    int removeRealByIds(Collection<? extends Serializable> ids);

    T getRealById(Serializable id);

    T getStrictById(Serializable id);

    T getRealStrictById(Serializable id);

    List<T> listReal();

    Page<T> pageReal(IPage<T> page);

    List<T> listRealByIds(Collection<? extends Serializable> ids);

    <R> T getOne(SFunction<T, R> sf, R r);

    <R> T getOneIn(SFunction<T, R> sf, Collection<R> cols);

    T getOne(Map<SFunction<T, ?>, ?> paramMap);

    T searchOne(Map<SFunction<T, ?>, ?> paramMap);

    <R> boolean exists(SFunction<T, R> sf, R r);

    <R> boolean existsIn(SFunction<T, R> sf, Collection<R> cols);

    boolean exists(Map<SFunction<T, ?>, ?> paramMap);

    <R> List<T> list(SFunction<T, R> sf, R r);

    List<T> listLike(SFunction<T, String> sf, String r);

    <R> List<T> listIn(SFunction<T, R> sf, Collection<R> cols);

    List<T> list(Map<SFunction<T, ?>, ?> paramMap);

    List<T> searchAll(Map<SFunction<T, ?>, ?> paramMap);

    <R> IPage<T> page(SFunction<T, R> sf, R r, IPage<T> page);

    <R> IPage<T> pageIn(SFunction<T, R> sf, Collection<R> cols, IPage<T> page);

    IPage<T> page(Map<SFunction<T, ?>, ?> paramMap, IPage<T> page);

    IPage<T> searchPage(Map<SFunction<T, ?>, ?> paramMap, IPage<T> page);

    <R> LambdaQueryChainWrapper<T> generateEqQueryChain(SFunction<T, R> sf, R r);

    <R> LambdaQueryChainWrapper<T> generateInQueryChain(SFunction<T, R> sf, Collection<R> cols);

    LambdaQueryChainWrapper<T> generateMapQueryChain(Map<SFunction<T, ?>, ?> paramMap);

    LambdaQueryChainWrapper<T> generateMapSearchQueryChain(Map<SFunction<T, ?>, ?> paramMap);

    <R> boolean updateById(SFunction<T, R> setSf, R r, Serializable id);

    boolean updateById(Map<SFunction<T, ?>, ?> setMap, Serializable id);

    <R, U> boolean update(SFunction<T, R> setSf, R r, SFunction<T, U> selectSf, U u);

    boolean update(Map<SFunction<T, ?>, ?> setMap, Map<SFunction<T, ?>, ?> selectMap);

    <R> boolean remove(SFunction<T, R> sf, R r);

    <R> boolean remove(SFunction<T, R> sf, Collection<R> cols);

    boolean remove(Map<SFunction<T, ?>, ?> selectMa);
}
